package com.huobao.yunying.adapters;

import java.util.Map;

import com.huobao.yunying.entity.Youhuiquan;
import com.huobao.yunying.https.Http;
import com.huobao.yunying.https.HttpListener;
import com.huobao.yunying.https.HttpUtil;
import com.huobao.zhangying.R;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;

public class Adapter_Youhuiquan extends QuickAdapter<Youhuiquan> {

	public Adapter_Youhuiquan(Context context) {
		super(context, R.layout.item_youhuiquan);
	}

	@Override
	protected void convert(BaseAdapterHelper arg0, final Youhuiquan arg1) {
		arg0.setText(R.id.tv_youhui, arg1.coupon_value).setText(R.id.tv_mane, "单笔满"+arg1.min_amount+"使用").setText(R.id.tv_youxiaoqi, "有效期："+arg1.start_time+" "+arg1.end_time).setOnClickListener(R.id.llyt,	 new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Map<String, String> map = HttpUtil.getParams("app","store","act","receivecoupon","coupon_id",arg1.coupon_id);
				Http.getInstant().sendRequest(context, map, new HttpListener() {
					
					@Override
					public void onHttpSuccess(String result) {
						Toast.makeText(context, "领取成功", Toast.LENGTH_SHORT).show();
					}
					
					@Override
					public void onHttpError(String error) {
						// TODO Auto-generated method stub
						
					}
				});
			}
		});
	}

}
